\newpage
\section*{Appendix A.}
\label{sec:appsys}
		 \lstset{
					basicstyle=\scriptsize\ttfamily,
					keywordstyle=\bf,
					tabsize=2,
					morekeywords={Class, Annotation, source, Attribute, Integer}
				}
				
\begin{center}\textbf{Sample meta-model for defining data sources in JOnAS}\end{center}				
\begin{lstlisting}[frame=tlbr]
Package(name="JOnASJMX"){
	Annotation(source="http://www.sei.pku.edu.cn/rsa"){
		"mainEntry"->{
			...
			mgmtHome = (ManagementHome) 
				PortableRemoteObject.narrow(
					initialContext.lookup("ejb/mgmt/MEJB"),
          ManagementHome.class);
      return mgmtHome.create();
		}
	Class(name="JDBCDataSource"){
		Annotation(source="http://www.sei.pku.edu.cn/rsa"){
			"rawtype"->{javax.management.ObjectName}
			"create"->{
					...
					$mainEntry.invoke(dbServerce,
							"loadDataSource",
							new String[]{getName(),pro,new Boolean(true)},
							new String[]{"java.lang.String",
								"java.util.Properties",
								"java.lang.Boolean"}
							)
				}
			"destroy"->{...}
		}
		Attribute(name="jdbcMaxConnPool", type=Interger, upperbound=1){
			Annotation(source="http://www.sei.pku.edu.cn/rsa"){
				"get"->{
						if($core==null) return "";
						$featureName=$mainEntry
							.getAttribute($core, $feature);
					}
				"set"->{...}
			}
		}	
		...
	}
	Class(name="MBeanServer"){
		Association(name="jdbcDataSource", containment=true){
			Annotation(source="http://www.sei.pku.edu.cn/rsa"){
				list->{
					ObjectName query=new ObjectName("jonas:j2eeType=$featurName");
					Set sets=$mainEntry.queryNames(query, null);
					$return.addAll(sets);
				}
				add->{...}
	...
}
\end{lstlisting}

\lstset{
					basicstyle=\scriptsize\ttfamily,
					keywordstyle=\bf,
					tabsize=2,
					language=Java
				}

\begin{center}\textbf{Code generated from the above meta-model}\end{center}
\begin{lstlisting}[frame=tlbr]
public class JOnASPackageImpl extends EPackageImpl...{
	...
	public Management getMainEntry(){
		...
  }
}

public class MBeanServerImpl extends WrappingEObjectImpl...{
	public List listSubCores(int featureID){
		switch(featureID){
		case JOnASPackage.MBEAN_SERVER__JDBC_DATA_SOURCE:
			...
			pack.getMainEntry.invoke(dbServerce,
					"loadDataSource",
					new String[]{getName(),pro,new Boolean(true)},
					new String[]{"java.lang.String",
						"java.util.Properties",
						"java.lang.Boolean"}
					)
			break;
		...
	}
	public EList<JDBCDataSource> getJdbcDataSource() {
		if (jdbcDataSource == null) {
			jdbcDataSource = new 
				EObjectContainmentEListForWrapping<JDBCDataSource>(
					JDBCDataSource.class, 
					this, 
					JOnASPackage.MBEAN_SERVER__JDBC_DATA_SOURCE,
					JOnASPackage.eINSTANCE.getJDBCDataSource()
				);
		}
		((EObjectContainmentEListForWrapping<JDBCDataSource>)
			jdbcDataSource).refreshWrap();
		return jdbcDataSource;
	}
	public Object eGet(int featureID,boolean resolve,boolean coreType){
		switch (featureID) {
		case JOnASPackage.MBEAN_SERVER__JDBC_DATA_SOURCE:
				return getJdbcDataSource();
		...
	}
	...
}

public class JDBCDataSourceImpl ...{
 
\end{lstlisting}

\begin{center}\textbf{The complete QVT specifying relation between C2 and JOnAS}\end{center}

\lstset{
		language=OCL,
		tabsize=1,
		basicstyle=\scriptsize\ttfamily,
		morekeywords={transformation, top, relation, enforce, domain, when,checkonly},
		keywordstyle=\bf
	}
\begin{lstlisting}[frame=tlbr]

transformation C2JOnAS(arc:C2, sys:JOnAS){
	key C2::Connector{name};
	key C2::Component{name};
	key C2::Architecture{deployedHost};
	key JOnAS::MBeanServer{serverHost};
	key JOnAS::EJB{name};
	key JOnAS::WebModule{name};
	
	top	relation Root2Root {		
		host : String;
		enforce domain arc s: C2::Architecture {
			deployedHost=host
		};		
		enforce domain sys t: JOnAS::MBeanServer {
			serverHost=host	
		};				
		when {
			s.parent.oclIsUndefined();
		}
	}
	
	top relation Component2EntityBean {		
		name : String;
		address : String;
		filePath : String;
		jdbc:String;		
		checkonly domain arc arch:C2::Architecture{};
		enforce domain arc conn:C2::Connector{
			name=address
		};
		enforce domain arc comp : C2::Component{
			name=name,
			address=address,
			filePath=filePath,
			type='Entity',
			below=conn,
			above = conn2 : C2::Connector{
								name=jdbc
							}
		};
				
		checkonly domain sys mbeanserver :JOnAS::MBeanServer{
		};		
		enforce domain sys entitybean : JOnAS::EntityBean{
			name=name,
			jndiName=address,
			fileName=filePath,
			parent=mbeanserver,
			dataSourceJNDI=jdbc
		};		
		when {
			Root2Root(arch,mbeanserver);
		}	
	}
	
	top relation Component2StatefulSessionBean {	
		name : String;
		address : String;
		filePath : String;
		instanceLife : Integer;		
		checkonly domain arc arch:C2::Architecture{};
		enforce domain arc conn:C2::Connector{
			name=address
		};
		enforce domain arc comp : C2::Component{
			name=name,
			address=address,
			filePath=filePath,
			type='DurativeOperation',
			below=conn,
			instanceLife=instanceLife
		};				
		checkonly domain sys server :JOnAS::MBeanServer{
		};		
		enforce domain sys sb : JOnAS::StatefulSessionBean{
			name=name,
			jndiName=address,
			fileName=filePath,
			parent=server,
			sessionTimeOut=instanceLife
		};		
		when {
			Root2Root(arch,server);
		}	
	}
	
	top relation Component2StatelessSessionBean {		
		name : String;
		address : String;
		filePath : String;
		instanceLife : Integer;
		jdbc : String;		
		checkonly domain arc arch:C2::Architecture{};
		enforce domain arc conn:C2::Connector{
			name=address
		};
		enforce domain arc comp : C2::Component{
			name=name,
			address=address,
			filePath=filePath,
			type='OneStopOperation',
			instanceLife=instanceLife,
			below=conn,
			above = conn2 : C2::Connector{
								name=jdbc
							}
		};
				
		checkonly domain sys server :JOnAS::MBeanServer{
		};		
		enforce domain sys sb : JOnAS::StatelessSessionBean{
			name=name,
			jndiName=address,
			fileName=filePath,
			parent=server,
			sessionTimeOut=instanceLife,
			dataSourceJNDI=jdbc
		};	
		
		when {
			Root2Root(arch,server);
		}	
	}
	
	top relation Component2WebModule {		
		name : String;
		address : String;
		filePath : String;
		refjndi : String;		
		checkonly domain arc arch : C2::Architecture{};
		enforce domain arc conn : C2::Connector{
			name='HTTP',
			parent=arch
		};
		enforce domain arc comp : C2::Component{
			name=name,
			address=address,
			filePath=filePath,
			below=conn,
			above=refconn : C2::Connector{
						name=refjndi
					}
		};				
		checkonly domain sys server : JOnAS::MBeanServer{};
		enforce domain sys webModule : JOnAS::WebModule{
			name=name,
			path=address,
			warURL=filePath,
			parent=server,
			ejbref=refjndi
		};			
		when {
			Root2Root(arch,server);
		}	
	}
	
	
	top relation Component2DataSource {
		
		name:String;
		address:String;		
		
		checkonly domain arc arch : C2::Architecture{};
		enforce domain arc conn : C2::Connector{
			name=address,
			parent=arch,
			type='jdbc'			
		};		
		enforce domain arc comp : C2::Component{
			below=conn,
			name=name,
			address=address,
			parent=arch
		};		
		checkonly domain sys server : JOnAS::MBeanServer{};
		enforce domain sys data : JOnAS::JDBCDataSource{
			jndiName=address,
			name=name,
			parent=server
		};		
		when{
			Root2Root(arch,server);
		}
	}
		
}
\end{lstlisting}


\begin{table}\scriptsize
	\centering
	\caption{A sample system meta-model}
	\label{tab:metasample1}
		\begin{tabular}{l}
		\hline
		 \lstset{
					basicstyle=\scriptsize\ttfamily,
					keywordstyle=\bf,
					tabsize=2,
					morekeywords={Class, Annotation, source, Attribute, Integer}
				}
		 \begin{lstlisting}
Package(name="JOnASJMX"){
	...
	Class(name="JDBCDataSource"){
		...
		Attribute(name="jdbcMaxConnPool", type=Interger, upperbound=1){
			Annotation(source="..."){
				"get"->{
						$featureName=((Interger)$mainEntry
							.getAttribute($core, "$feature")).intValue();
					}
			}
		}	
		...
	}
}
		 \end{lstlisting}
		\\ \hline    			
		\end{tabular}
\end{table}

\begin{table}\scriptsize
	\centering	
	\caption{A sample generated adapter}
	\label{tab:sysadapter1}	
	\begin{tabular}{l}
		\hline
		 \lstset{
					basicstyle=\scriptsize\ttfamily,
					keywordstyle=\bf,
					tabsize=2,
					language=Java
				}
		 \begin{lstlisting}
public class JOnASPackageImpl extends EPackageImpl...{
	...
	public Management getMainEntry(){...}
}
public class JDBCDataSourceImpl 
	extends CommonWrappingEObjectImpl ...{
	public int getJdbcMaxConnPool() {
		jdbcMaxConnPool=((Interger)JOnASPackage.eINSTANCE.getMainEntry()
							.getAttribute(getCore(), "jdbcMaxConnPool")).intValue();
		return jdbcMaxConnPool;
	}
	public Object eGet(int featureID,boolean resolve,boolean coreType){
		switch (featureID) {
			case JOnASPackage.JDBC_DATA_SOURCE__JDBC_MAX_CONN_POOL:
				return new Integer(getJdbcMaxConnPool());
		...
	}		
}
	 \end{lstlisting}
		\\ \hline    			
		\end{tabular}
\end{table}
			
